package com.example.dqhl.recycleviewdemo.login;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;


import com.example.dqhl.recycleviewdemo.R;
import com.example.dqhl.recycleviewdemo.adapter.SimpleImageAdapter;
import com.example.dqhl.recycleviewdemo.base.ControlBaseActivity;
import com.example.dqhl.recycleviewdemo.modle.ImageData;

import java.util.ArrayList;
import java.util.List;

import com.example.dqhl.recycleviewdemo.widget.CursorWheelLayout;

/**
 * Created by dell on 2017/8/1.
 */

public class LoginView extends ControlBaseActivity<LoginPresenter> implements ILoginView, View.OnClickListener {

    private CursorWheelLayout test_circle_menu_top;

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    public LoginPresenter createPresenter() {
        return new LoginPresenter(this);
    }

    @Override
    protected int getContentViewResource() {
        return R.layout.activity_login_cursor;
    }

    private TextView mLogin;
    private EditText mUsername;



    @Override
    protected void onViewInit() {
        super.onViewInit();

        (mLogin) = (TextView) findViewById(R.id.tv_login);
        (mUsername) = (EditText) findViewById(R.id.et_username);

        (test_circle_menu_top) = (CursorWheelLayout) findViewById(R.id.test_circle_menu_top_login);

        List<ImageData> imageDatas = new ArrayList<ImageData>();
        imageDatas.add(new ImageData(R.mipmap.loading, "0"));
        imageDatas.add(new ImageData(R.mipmap.loading, "1"));
        imageDatas.add(new ImageData(R.mipmap.loading, "2"));
        imageDatas.add(new ImageData(R.mipmap.loading, "3"));
        imageDatas.add(new ImageData(R.mipmap.loading, "4"));
        imageDatas.add(new ImageData(R.mipmap.loading, "5"));
        SimpleImageAdapter simpleImageAdapter = new SimpleImageAdapter(getContext(), imageDatas);
        test_circle_menu_top.setAdapter(simpleImageAdapter);
        test_circle_menu_top.setOnMenuSelectedListener(new CursorWheelLayout.OnMenuSelectedListener() {
            @Override
            public void onItemSelected(CursorWheelLayout parent, View view, int pos) {
                Toast.makeText(getContext(), "Top Menu selected position:" + pos, Toast.LENGTH_SHORT).show();
            }
        });
        test_circle_menu_top.setOnMenuItemClickListener(new CursorWheelLayout.OnMenuItemClickListener() {
            @Override
            public void onItemClick(View view, int pos) {
                Toast.makeText(getContext(), "Top Menu click position:" + pos, Toast.LENGTH_SHORT).show();

            }
        });
    }

    @Override
    protected void setOnListener() {
        super.setOnListener();
        mLogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_login:
//                mPresenter.DoLogin();
                break;
        }
    }

    @Override
    public String getEditText() {
        return mUsername.getText().toString();
    }

    @Override
    public void SetEditText(String text) {
        mLogin.setText(text);
    }



}
